/*************************************************
Author: will
Date: 8/23/2012
Description:
Notes: 
*************************************************/

#ifndef __CBattleData_h__
#define __CBattleData_h__

#include "commclass.h"
#include "commerrno.h"
#include "../skill/CSkill.h"

class CBattleRoleData
{
public:
    CBattleRoleData()
    {
        Clear();
    }

    void Clear()
    {
        _bAngerOpen = false;
        _bIsLeft = false;
        _bIsMale = false;
        _chType = 0;
        _ucOrder = 0;
        _ucCareer = 0;
        _shLevel = 0;
        _iGridPos = 0;
        _iHP = 0;
        _iHPMax = 0;
        _iAnger = 0;
        _iAngerMax = 0;
        _iCourage = 0;
        _iCourageMax = 0;
        _iAngerRecRate = 0;
        _iCourageRecRate = 0;
        _iBattleID = 0;
        _uiObjID = 0;
        _uiMountID = 0;
        _uiWingID = 0;
        _uiDressID = 0;
        _sObjName.Set("");;
	    _stEquip.Clear();
        _stAttr.Clear();
        _stStatusList.Clear();
        _stNormalSkill.Clear();
        _stMagicSkill.Clear();
    }

    int CheckData()
    {
        if (_iGridPos < 0 || _iGridPos >= MAX_BATTLE_GRIDS_PER_SIDE)
        {
            return ERROR_BATTLE_GRID_ID;
        }

        if (_ucOrder >= MAX_BATTLE_ROLES_PER_SIDE)
        {
            return ERROR_BATTLE_TURN_ORDER;
        }
        
        return 0;
    }

    bool HasDead() const {return (_iHP <= 0);}

    void DumpRoleData(CPlayerAttr& stBattleAttr, CPlayerAttr& stTurnMainAttr,
            CPlayerAttr& stTurnMinorAttr, bool bIsTurnBegin);

public:    
    bool                _bAngerOpen;        //是否怒气系统开放
    bool                _bIsLeft;           //是否攻击方
    bool                _bIsMale;           //性别(真:男 假:女)
    char                _chType;            //个体类型(1:主角 2:伙伴 3:怪物)
    unsigned char       _ucOrder;           //出手(从0开始)
    unsigned char       _ucCareer;          //职业
    short               _shLevel;           //等级
    int                 _iGridPos;          //初始站位(从0开始)
    int                 _iHP;               //当前血量
    int                 _iHPMax;            //最大血量
    int                 _iAnger;            //当前怒气
    int                 _iAngerMax;         //最大怒气
    int                 _iCourage;          //当前勇气
    int                 _iCourageMax;       //最大勇气
    int                 _iAngerRecRate;
    int                 _iCourageRecRate;
    int                 _iBattleID;

    //个体ID(主角:角色GID 伙伴:配置ID 怪物:配置ID)
    unsigned int        _uiObjID;
    unsigned int        _uiMountID;//坐骑ID
    unsigned int        _uiWingID;//翅膀ID
    unsigned int        _uiDressID;//装扮ID

    CTSizeString<MAX_BATTLE_OBJ_NAME_LEN> _sObjName;

	CPlayerEquip        _stEquip;           //角色装备
    CPlayerAttr         _stAttr;            //角色属性

    CStatusList         _stStatusList;      //状态列表

    CSkill              _stNormalSkill;        //普通技能
    CSkill              _stMagicSkill;         //幻化技能
};

class CBattleRoleList
{
public:
    CBattleRoleList()
    {
        Clear();
    }
    void Clear()
    {
        _astRoleData.Clear();
    }

    bool IsAllRoleDataDead()
    {
        for (int i = 0; i < _astRoleData.Size(); ++i)
        {
            if (!_astRoleData[i].HasDead())
            {
                return false;
            }
        }
        return true;
    }

public:
    CTLib::CTArray<CBattleRoleData, MAX_BATTLE_ROLES_PER_SIDE> _astRoleData;
};

typedef CTLib::CTArray<int, MAX_BATTLE_ROLES_PER_SIDE> T_BATTLE_SIDE_DATA;

#endif // __CBattleData_h__

